﻿using ReactiveUI;
using Rougamo;
using Rougamo.Context;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AopCommon
{
    public class LoggingAttribute : MoAttribute
    {
        public override AccessFlags Flags => AccessFlags.All;
        //private StringBuilder 



        public override void OnEntry(MethodContext context)
        {
          
            MessageBus.Current.SendMessage<PromptMsg>($"方法{context.Method} 开始执行  时间${DateTime.Now.ToString("yyyyMMdd HH: mm:ss: fff")}");

        }

        public override void OnSuccess(MethodContext context)
        {
            MessageBus.Current.SendMessage<PromptMsg>($"方法{context.Method} 执行成功·  时间${DateTime.Now.ToString("yyyyMMdd HH: mm:ss: fff")}");

        }

        public override void OnException(MethodContext context)
        {
            MessageBus.Current.SendMessage<PromptMsg>($"方法{context.Method} 执行异常·  时间${DateTime.Now.ToString("yyyyMMdd HH: mm:ss: fff")}");

        }

        public override void OnExit(MethodContext context)
        {
            MessageBus.Current.SendMessage<PromptMsg>($"方法{context.Method} 退出·  时间${DateTime.Now.ToString("yyyyMMdd HH: mm:ss: fff")}");

        }
    }
}
